SOURCES = $(wildcard *.c)
TESTS = $(basename $(SOURCES))

CILLY = $(OBJ)/cilly.byte.exe

all: compare

big: cfrac

$(TESTS): %: %.c FORCE
	@mkdir -p temp
	$(CC) -m32 -E $< -o temp/$@.i
	CIL_MACHINE=`$(OBJ)/machdep-ml32.exe --env` \
	  $(CILLY) --dollvm --envmachine temp/$@.i >temp/$@.ll
	llvm-as -f temp/$@.ll
	llc -march=x86 -f temp/$@.bc
	$(CC) -m32 -o temp/$@.llvm temp/$@.s
	temp/$@.llvm

compare:
	@sh compare-with-gcc $(OBJ)

cfrac:
	make -C cfrac.d

clean:
	rm -rf temp
	make -C cfrac.d clean

FORCE:
.PHONY: FORCE big cfrac

